package com.huawei.appmarket.service.store.awk.card;

import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RelativeLayout.LayoutParams;
import com.huawei.appgallery.foundation.card.base.card.BaseDistCard;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appmarket.service.store.awk.bean.AppWelfareListCardBean;
import com.huawei.fastengine.fastview.download.utils.PackageUtils;
import huawei.widget.HwTextView;
import java.lang.ref.WeakReference;
import o.azb;
import o.ces;
import o.cet;
import o.ceu;
import o.cgz;
import o.chy;
import o.cil;
import o.cim.a;
import o.ContentManager;
import o.ein;
import o.eqx;
import o.evx;
import o.ewm.i;
import o.ewm.j;

public class AppWelfareListCard extends BaseDistCard {
    private HwTextView ʼ;
    private ImageView ʽ;
    private ImageView ˋ;
    private View ॱॱ;
    private HwTextView ᐝ;

    static class d implements ces {
        WeakReference<AppWelfareListCardBean> ˊ;
        AppWelfareListCard ˋ;
        WeakReference<chy> ˎ;
        WeakReference<Context> ˏ;

        d(AppWelfareListCardBean appWelfareListCardBean, chy o_chy, Context context) {
            this.ˊ = new WeakReference(appWelfareListCardBean);
            this.ˎ = new WeakReference(o_chy);
            this.ˏ = new WeakReference(context);
            this.ˋ = new AppWelfareListCard(context);
            this.ˋ.ˊᐝ = appWelfareListCardBean;
        }

        public void onResult(int i) {
            AppWelfareListCardBean appWelfareListCardBean = (AppWelfareListCardBean) this.ˊ.get();
            if (appWelfareListCardBean != null) {
                ein.ˊ(i, PackageUtils.HWGAMEBOX_PACKAGE_NAME, appWelfareListCardBean.ॱॱ());
            }
            AppWelfareListCard.ˏ(i, (chy) this.ˎ.get(), (AppWelfareListCardBean) this.ˊ.get(), (Context) this.ˏ.get(), this.ˋ);
        }
    }

    public /* synthetic */ CardBean ˌ() {
        return ˎ();
    }

    public AppWelfareListCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        this.ˋ = (ImageView) view.findViewById(j.ʴॱ);
        this.ʼ = (HwTextView) view.findViewById(j.ʹˋ);
        this.ᐝ = (HwTextView) view.findViewById(j.ʹˊ);
        this.ʽ = (ImageView) view.findViewById(j.ˎͺ);
        this.ॱॱ = view.findViewById(j.ᐧᐝ);
        ʽ(view);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        if (cardBean instanceof AppWelfareListCardBean) {
            ((LayoutParams) this.ˋ.getLayoutParams()).setMarginStart(ˊ());
            ((LayoutParams) this.ʽ.getLayoutParams()).setMarginEnd(ˋ());
            cardBean = (AppWelfareListCardBean) cardBean;
            ˎ(cardBean);
            this.ʼ.setText(cardBean.v_());
            String quantityString = ContentManager.getInstant().getContext().getResources().getQuantityString(i.ˏˎ, cardBean.ʽ(), new Object[]{Integer.valueOf(cardBean.ʽ())});
            String quantityString2 = ContentManager.getInstant().getContext().getResources().getQuantityString(i.ˋᐝ, cardBean.ॱ(), new Object[]{Integer.valueOf(cardBean.ॱ())});
            String quantityString3 = ContentManager.getInstant().getContext().getResources().getQuantityString(i.ˍ, cardBean.ꓸ(), new Object[]{Integer.valueOf(cardBean.ꓸ())});
            StringBuilder stringBuilder = new StringBuilder("");
            if (cardBean.ʽ() != 0) {
                stringBuilder.append(quantityString);
            }
            if (cardBean.ॱ() != 0) {
                if (!stringBuilder.toString().isEmpty()) {
                    stringBuilder.append("  ");
                }
                stringBuilder.append(quantityString2);
            }
            if (cardBean.ꓸ() != 0) {
                if (!stringBuilder.toString().isEmpty()) {
                    stringBuilder.append("  ");
                }
                stringBuilder.append(quantityString3);
            }
            this.ᐝ.setText(stringBuilder.toString());
            this.ॱॱ.setVisibility(ˊᐝ() ? 0 : 8);
        }
    }

    private void ˎ(CardBean cardBean) {
        if (TextUtils.isEmpty(cardBean.ॱˑ())) {
            eqx.ˏ(this.ˋ, cardBean.ॱˌ(), "app_default_icon");
        } else {
            eqx.ॱ(this.ˋ, cardBean.ॱˑ(), "app_default_icon");
        }
        this.ˋ.setContentDescription(cardBean.v_());
    }

    public AppWelfareListCardBean ˎ() {
        if (this.ˊᐝ instanceof AppWelfareListCardBean) {
            return (AppWelfareListCardBean) this.ˊᐝ;
        }
        return null;
    }

    public void ॱ(final chy o_chy) {
        OnClickListener anonymousClass5 = new evx(this) {
            final /* synthetic */ AppWelfareListCard ॱ;

            public void ˋ(View view) {
                if (this.ॱ.ʼ()) {
                    o_chy.ˏ(0, this.ॱ);
                    return;
                }
                new ceu((Activity) this.ॱ.ʼॱ).ˊ(new cet(PackageUtils.HWGAMEBOX_PACKAGE_NAME, "gamebox", 100200110), new d(this.ॱ.ˎ(), o_chy, this.ॱ.ʼॱ));
            }
        };
        this.ˋ.setOnClickListener(anonymousClass5);
        ˉ().setOnClickListener(anonymousClass5);
    }

    private static void ˏ(int i, chy o_chy, AppWelfareListCardBean appWelfareListCardBean, Context context, AppWelfareListCard appWelfareListCard) {
        if (i == 2000 || i == 2001 || i == 2002) {
            o_chy.ˏ(0, appWelfareListCard);
        } else if (i == 2100 || i == 2101 || i == 2102 || i == 2103 || i == 2200 || i == 2201 || i == 2202 || i == 2300 || i == 2301) {
            cil.ˋ(context, new a(appWelfareListCard.ˎ()).ˋ());
        }
    }

    private boolean ʼ() {
        return PackageUtils.HWGAMEBOX_PACKAGE_NAME.equals(ContentManager.getInstant().getContext().getPackageName());
    }

    protected int ˊ() {
        return azb.ˊ(this.ˊˋ.getContext());
    }

    protected int ˋ() {
        return azb.ˏ(this.ˊˋ.getContext());
    }
}
